/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fmsactionserver.client;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author rbs
 */
public class FMSActionClient{
    
    public static void main(String[] args) {
        
        if (args.length != 4)
            System.exit(-1);
        
        File ip = new File("ip.txt");
        BufferedReader bufreader = null;
        try {
            bufreader = new BufferedReader(new FileReader(ip));
        } catch (FileNotFoundException ex) {
            Logger.getLogger(FMSActionClient.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        while (true)
        {
            String ipAddr = null;
            try {
                 ipAddr = bufreader.readLine();
                if (ipAddr != null)
                {
                    ipAddr.replace(" ", "");
                    if (!ipAddr.startsWith("#") && !ipAddr.equals("")) //sonst Kommentar
                    {    
                        //System.out.println("Connecting to " + ipAddr);
                        InputSender inputSender = new InputSender(args[0], args[1], args[2], args[3], ipAddr);
                        inputSender.start();
                    }
                }
                else
                    break;
            } catch (IOException ex) {
                Logger.getLogger(FMSActionClient.class.getName()).log(Level.SEVERE, null, ex);
                //System.out.println("Error on connecting to " + ipAddr);
            }
        }
        try {
            bufreader.close();
        } catch (IOException ex) {
            Logger.getLogger(FMSActionClient.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
